<%@page import="entidades.Usuario"%>
<%
    if (session.getAttribute("usuario") == null) {
        response.sendRedirect("index.jsp");
    }
%>
<%-- 
    Document   : inserirProduto
    Created on : 30/05/2012, 01:15:49
    Author     : user
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link rel="stylesheet" href="css/style.css" type="text/css" />
        <title>Inserir Produto</title>

        <script src="js/jquery.js" type="text/javascript"></script>        
        <script type="text/javascript">
            
            $(function(){
                $('#add').click(function(){
                    $('#campos').append('<p><input type="file" name="foto" /><button class="delInput">Remover</button></p>');                 
                });
                
                $('.delInput').live('click', function(){
                    if(confirm('Remove mesmo?')){
                        $(this).parent().remove();
                    }
                    return false;
                });
                
            });
        </script> 

    </head>
    <body>
        <%
            Usuario usuario = (Usuario) session.getAttribute("usuario");
            if (usuario != null) {
        %>
        <div id="topo">
            <a href="index.jsp"> <img src="imagens/centralLogo.png" width="400" height="200"/> </a>
        </div>
        <div id="menu">
            <ul>
                <li style="float: right">
                    <p style="color: white; float:right">Olá <%=usuario.getNome()%></p>
                    <br/>
                    <p style="float: right; color: #900"><a href="LoginServlet?op=Sair">sair</a></p>
                </li>
            </ul>
        </div>
        <div id="conteudo">
            <form action="ProdutoServlet" name="InserirProduto" method="post" enctype="multipart/form-data">
                <fieldset style="height: 100%;">
                    <legend> Inserir Produto </legend>

                    <table border="0" cellspacing="2">
                            <tr>
                                <td>
                                    <label>
                                        <span>Nome:</span> 
                                        <input type="text" name="nome" value="" />               
                                    </label>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <label>
                                        <span>Pre&ccedilo:</span> 
                                        <input type="text" name="valor" value="" />               
                                    </label>

                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <label class="textarea">
                                        <span>Descri&ccedil&atildeo</span >
                                        <textarea name="descricao" cols="80" rows="4" ></textarea>
                                    </label>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <div id="img">          
                                        <br />
                                        <br />
                                        <br />
                                        <label><span>Fotos</span></label>

                                        <div id="campos"></div>
                                        <div><input type="button" value="Adicionar imagens" name="add_input" id="add" /></div>

                                    </div>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <label>
                                        <fieldset class="botao" >
                                            <input type="submit" id="upload" name="op" value="Inserir" />
                                        </fieldset>
                                    </label>
                                </td>
                            </tr>
                    </table>

                </fieldset>
            </form>
        </div>
        <%
            }
        %>
    </body>
</html>
